1 <?php
2 session_start();
3 if(isset($_SESSION['user']))
4 {
5
6 }
7 else{
8 echo"<script>location.href='login.html'</script>";
9 }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14 <title>
15 Salesdetails
16 </title>
17 <style>
18
19 body {
20 margin: 0;
21 font-family: Arial, Helvetica, sans-serif;
22 background: #484848;
23 }
24 .topnav {
25 overflow: hidden;
26 background-color: rgba(249, 105, 14, 1);
27 height: 70px;
28 border: 3px solid #e69500;
29 }
30
31 .topnav a {
32 float: left;
33 color: #f2f2f2;
34 text-align: center;
35 padding: 14px 16px;
36 text-decoration: none;
37 font-size: 35px;
38 font-weight: bold;
39 }
40
41 .topnav-right {
42 float: right;
43 }
44
45 fieldset { max-width: 450px;
46 background: #FAFAFA;
47 padding: 30px;
48 margin: 50px auto;
49 box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
50 border-radius: 10px;
51 border: 6px solid rgba(249, 105, 14, 1);
52
53
54 }
55
56 legend {
57 padding: 0.2em 0.5em;
58 border:2px solid rgba(249, 105, 14, 1);
59 color:green;
60 font-size:90%;
61 text-align:center;
62 }
63 </style>
64 </head>
65 <body>
66 <div class="topnav">
67 <a class="active" href="home.html"><img src="ic_add_pet.png"></a>
68 <a href="sales.php">Sales details</a>
69 <div class="topnav-right">
70 <a href="logout.php">logout</a>
71 </div>
72 </div>
73
74 <form>
75 <button type="submit" formaction="sales.php" style="margin:15px;height: 30px;width: 100px;cursor:pointer;
76 border-radius:15px;
77 border: 3px solid #e69500;background-color: rgba(249, 105, 14, 1);color:#f2f2f2;font-size:15px;">back</button>
78 </form>
79 <form method="post" action="salesadd.php">
80
81 <fieldset>
82
83 <input type="text" id ="sd" name="id" placeholder="Enter the sales id" style="width:100%;height:30px;
84 border: 2px solid rgba(249, 105, 14, 1); border-radius:5px;" required>
85 <br><br>
86 <input type="text" name="csid" placeholder="Enter the customer id" style="width:100%;height:30px;
87 border: 2px solid rgba(249, 105, 14, 1);border-radius:5px; " required>
88 <br><br>
89 <input type="date" name="date" style="width:100%;height:30px;
90 border: 2px solid rgba(249, 105, 14, 1);border-radius:5px;" required>
91 <br><br>
92 <input type="submit" name="submit" value="save" style="width:100%;height:30px;border-radius:5px;
93 border: 2px solid rgba(249, 105, 14, 1); cursor:pointer;background-color: rgba(249, 105, 14, 1)"> 
94 </fieldset>
95
96 </form>
97 </body>
98 </html>
99 <?php
100 if(isset($_POST["submit"]))
101 {
102 // define variables and set to empty values
103 $servername = "localhost";
104 $username = "root";
105 $password = "";
106 $dbname = "Petshop_management";
107
108 // Create connection
109 $conn = new mysqli($servername, $username, $password, $dbname);
110 // Check connection
111 if ($conn->connect_error) {
112 die("Connection failed: " . $conn->connect_error);
113 }
114 //echo " CONNECTION ESTABLISHED \r\n";
115 //echo " INSERTION IN PROCESS";
116 $id = $_POST["id"];
117 $cs_id = $_POST["csid"];
118 $date= $_POST["date"];
119 // $total = $_POST["total"];
120
121
122
123
124
125 $sql = "INSERT INTO sales_details( sd_id,cs_id,date)
126 VALUES ('$id','$cs_id','$date')";
127 if ($conn->multi_query($sql) == TRUE) {
128 echo'<div>
129 <h1 style="color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">New record of id='
130 .$id. ' inserted successfully</h1>
131 </div>';
132 }
133 else {
134 echo "Error: " . $sql . "<br>" . $conn->error;
135 }
136
137 $conn->close();
138 }
139
140
141 ?>